package com.sctvcloud.dongqu.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;
import com.ruihang.generalibrary.ui.util.OnItemInternalClick;
import com.sctvcloud.dongqu.R;
import com.sctvcloud.dongqu.beans.FRebellion;
import com.sctvcloud.dongqu.ui.adapter.holder.BaseRebllionHolder;
import com.sctvcloud.dongqu.ui.adapter.holder.RebllionPicHolder;
import com.sctvcloud.dongqu.ui.util.IListShowData;

import java.util.List;

/**
 * Created by Administrator on 2017/6/26 0026.
 */

public class RebllionAdapter extends BaseHolderAbsAdapter<IListShowData, BaseRebllionHolder> implements OnItemInternalClick {
    private OnItemInternalClick onItemInternalClick;
    private OnVideoClickListener mListener;

    public RebllionAdapter(Context context, List<IListShowData> list) {
        super(context, list);
    }

    @Override
    public BaseRebllionHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        BaseRebllionHolder rebllionHolder;
        LayoutInflater inflater = LayoutInflater.from(context);
        rebllionHolder = new RebllionPicHolder(context, inflater.inflate(R.layout.item_rebllion_pic, parent, false));
        rebllionHolder.setInternalClick(this);
        return rebllionHolder;
    }

    @Override
    public int getItemViewType(int position) {
        return data.get(position).getDataType();
    }

    @Override
    public void onItemInternalClick(View itemView, View view, int position) {
        if (onItemInternalClick != null) {
            onItemInternalClick.onItemInternalClick(itemView, view, position);
        }
    }

    @Override
    public RebllionAdapter setItemInternalClick(OnItemInternalClick itemInternalClick) {
        this.onItemInternalClick = itemInternalClick;
        return this;
    }

    public void setOnVideoClickListener(OnVideoClickListener listener) {
        mListener = listener;
    }

    public interface OnVideoClickListener {
        void onVideoClick(View view, View coverImgView, FRebellion fRebellion);
    }
}
